﻿Public Class frmCapNhatThongTin
    Public _svDTO As New SinhVienDTO
    Public _svBUS As New SinhVienBUS
    Public _cnDTO As New ChuNhaDTO
    Public _cnBUS As New ChuNhaBUS
    Public _tkDTO As New TaiKhoanDTO
    Public _tkBUS As New TaiKhoanBUS
    Private Sub frmCapNhatThongTin_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If _tkDTO.MaLoai = 2 Then
            txtCMND.Text = _svDTO.CMND
            txtHoTen.Text = _svDTO.HoTen
            txtDienThoai.Text = _svDTO.DienThoai
            txtEmail.Text = _svDTO.Email
            txtTruong.Text=_svDTO.Truong
        ElseIf _tkDTO.MaLoai = 3 Then
            txtCMND.Text = _cnDTO.CMND
            txtHoTen.Text = _cnDTO.HoTen
            txtDienThoai.Text = _cnDTO.DienThoai
            txtEmail.Text = _cnDTO.Email
            txtTruong.Enabled=False
        End If
    End Sub

    Private Sub btnThoat_Click_1(sender As System.Object, e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub

    Private Sub btnCapNhat_Click_1(sender As System.Object, e As System.EventArgs) Handles btnCapNhat.Click
        Dim result As DialogResult = MessageBox.Show("Bạn có chắc chắn muốn thay đổi?", "Thông báo", MessageBoxButtons.YesNo)
        If result = DialogResult.Yes Then
            If _tkDTO.MaLoai = 2 Then
                _svDTO.HoTen = txtHoTen.Text
                _svDTO.Truong = txtTruong.Text
                _svDTO.Email = txtEmail.Text
                _svDTO.DienThoai = txtDienThoai.Text
                _svDTO.CMND = txtCMND.Text
                _svBUS.Update(_svDTO)
                Me.Close()
            ElseIf _tkDTO.MaLoai = 3 Then
                _cnDTO.HoTen = txtHoTen.Text
                _cnDTO.Email = txtEmail.Text
                _cnDTO.DienThoai = txtDienThoai.Text
                _cnDTO.CMND = txtCMND.Text
                _cnBUS.Update(_cnDTO)
                Me.Close()
            End If
        End If
    End Sub
End Class